/*
 * @Author: 李石
 * @Date: 2024-05-20 19:45:19
 * @LastEditors: lishi
 * @LastEditTime: 2024-07-16 11:48:16
 * @Description: 
 * Copyright (c) 2024 by ${lishi0105@163.com}, All Rights Reserved. 
 */
#ifndef NALU_PARSE_H
#define NALU_PARSE_H

#include "H264Stream.h"
#include "H265Stream.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
    int type;                       // 0 -- h.264; 1 -- h.265
    unsigned int num;               // 序号
    unsigned int len;               // 含起始码的总的长度
    unsigned int offset;            // nal包在文件中的偏移
    int sliceType;                  // 帧类型
    int nalType;                    // NAL类型
    int first_mb_in_slice;          // 第一个宏块的位置
    int startcodeLen;               // start code长度
} NALU_t;

typedef struct 
{
    int profile_idc;
    int level_idc;
    int width;
    int height;
    int crop_left;
    int crop_right;
    int crop_top;
    int crop_bottom;
    float fps;  // 由SPS计算得到的帧率，为0表示SPS中没有相应的字段计算
    int chroma_format_idc;  // YUV颜色空间 0: monochrome 1:420 2:422 3:444
}SPSInfo_t;

typedef struct 
{
    int encoding_type;  // 为1表示CABAC 0表示CAVLC

}PPSInfo_t;

typedef enum{
    NALU_VIDEO_H264 = 0,
    NALU_VIDEO_H265 = 1,
    NALU_VIDEO_HEVC = NALU_VIDEO_H265,
}NALU_VIDEO_TYPE;

typedef enum{
    NaluFalse = 0x0,
    NaluTrue = 0x1
}NaluBoolean;

char keyframe(NALU_t *);
char configFrame(NALU_t *);
char dropAble(NALU_t *);
char decodeAble(NALU_t *);
// type 0: 264; 1: 265
// return 0: not key frame; 1: key frame
char _keyframe(int type, const uint8_t *in, size_t size, int32_t *startLen_);
char _configFrame(int type, const uint8_t *in, size_t size, int32_t *startLen_);
char _dropAble(int type, const uint8_t *in, size_t size, int32_t *startLen_);
char _decodeAble(int type, const uint8_t *in, size_t size, int32_t *startLen_);

#ifdef __cplusplus
}
#endif
#endif
